using imitateMacQQ.WebApi.Domain.CircleServe.Entity.dto;
using imitateMacQQ.WebApi.Domain.CircleServe.Interface;
using imitateMacQQ.WebApi.Domain.Request.utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace imitateMacQQ.WebApi.Api.Circle;

[ApiController]
[Route("api/[controller]/[action]")]
public class CircleController : ControllerBase
{
    private readonly IReleaseInfo _releaseInfo;
    private readonly IUpvote _upvote;

    public CircleController(IReleaseInfo releaseInfo, IUpvote upvote)
    {
        _releaseInfo = releaseInfo;
        _upvote = upvote;
    }

    [HttpPost]
    public async Task<Request<bool>> Release([FromHeader] string account,
        [FromHeader] bool isShow)
    {
        var files1 = Request.Form.Files;
        Request.Form.TryGetValue("content", out var content);

        var dto = new ReleaseInfo()
        {
            SendAccount = account,
            Content = content,
            PrintPicture = "",
            IsShow = isShow
        };

        var res = await _releaseInfo.Release(files1, dto);
        return res;
    }

    [Authorize]
    [HttpPost]
    public async Task<Request<bool>> ClickLike(Upvote dto)
    {
        return await _upvote.UpvoteServe(dto);
    }

    [HttpGet]
    public async Task<Request<string[]>> GetLike(string remarks)
    {
        return await _upvote.GetLikeList(remarks);
    }
}